
using System;
using System.Collections.Generic;
using BTKERP.Model;
using BTKERP.DAL.DataAccess;
using System;

namespace BTKERP.DAL
{
	#region CountryDAL
	public class CountryDAL : DBContext
	{
		public List<Country> GetAll()
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_CountriesSelectAll");
            return GetEntityList<Country>(cmd);
        }

        public Country GetById(Guid id)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_CountrySelect");
            cmd.AddParameter("@Id", id);
            return GetSingleEntity<Country>(cmd);
        }

		public List<Country> GetByDynamicSQL(string sqlCondition)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_CountrySelectDynamic");
            cmd.AddParameter("@SQL", sqlCondition);
            return GetEntityList<Country>(cmd);
        }

        public Country Add(string paramName, string paramDescription, string paramCountryCode, string paramLanguage, string paramCreatedBy)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_CountryInsert");
            cmd.AddParameter("@Name", paramName);
            cmd.AddParameter("@Description", paramDescription);
            cmd.AddParameter("@CountryCode", paramCountryCode);
            cmd.AddParameter("@Language", paramLanguage);
            cmd.AddParameter("@UpdatedBy", paramCreatedBy);
            return GetSingleEntity<Country>(cmd);
        }

        public bool DeleteById(Guid id)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_CountryDelete");
            cmd.AddParameter("@Id", id);
            return ExecuteCommand(cmd);
        }

        public Country UpdateById(Guid paramId, string paramName, string paramDescription, string paramCountryCode, string paramLanguage, string paramUpdatedBy)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_CountryUpdate");
			cmd.AddParameter("@Id", paramId);
			cmd.AddParameter("@Name", paramName);
			cmd.AddParameter("@Description", paramDescription);
			cmd.AddParameter("@CountryCode", paramCountryCode);
			cmd.AddParameter("@Language", paramLanguage);
			cmd.AddParameter("@UpdatedBy", paramUpdatedBy);
            return GetSingleEntity<Country>(cmd);
        }
		
	}
	#endregion
}
